﻿#include<iostream>
#include<mysql.h>
#include "database.h"
#include"manager.h"
using namespace std;


const string ip = "127.0.0.1";
const string user = "root";
const string password = "123456";
const string dbname = "bookmanage";
const int port = 3306;
void loginmenu(string &name,string &pass) {
	cout << "请输入用户名：";
	cin >> name;
	cout << "请输入密码：";
	cin >> pass;
}

void manager_table(string name, string pass) {
	Manager m(name, pass);/*实例*/
	m.db.connect(ip, user, password, dbname, port);
	if (m.login(name, pass,"manage")) {
		m.menu();
	}
	else {
		cout << "登陆失败！！！" << endl;
	}
}
void menu() {
	system("cls");
	cout << "\t***********************************************************" << endl;
	cout << "\t*                                                         *" << endl;
	cout << "\t*                    1、管理员登录                        *" << endl; 
	cout << "\t*                                                         *" << endl;
	cout << "\t*                    2、学生登录                          *" << endl;
	cout << "\t*                                                         *" << endl;
	cout << "\t*                    3、教师登录                          *" << endl;
	cout << "\t*                                                         *" << endl;
	cout << "\t***********************************************************" << endl;
	string name;
	string pass;
	int num;
	cin >> num;
	switch (num) {
	case 1:
		loginmenu(name, pass);
		manager_table(name, pass);
		break;
	case 2:
		loginmenu(name, pass);
		break;
	case 3:
		loginmenu(name, pass);
		break;
	default:
		cout << "错误操作！！！" << endl;
		menu();
	}
}

int main() {
	menu();
}